namespace CodeConsult.Nordic.nRF8001.ApplicationControlInterface.Commands.DataCommands
{
    public class SendDataNackCommand : AciCommandBase
    {
        public const byte OpCode = 0x018;

        public byte PipeNumber { get; set; }
        public byte ErrorCode { get; set; }

        protected override void EncodeBuffer()
        {
            Error = Error || PipeNumber < 1 || PipeNumber > 62;
            Error = Error || ErrorCode < 0x80;

            if (Error) return;

            EncodeBufferWithCommandHeader(OpCode, 2);
            EncodeHelper.SetByte(PipeNumber);
            EncodeHelper.SetByte(ErrorCode);
        }
    }
}
